package com.dt76.smallloanbackenduser.controller.yaozhao;

import com.dt76.smallloanbackenduser.remote.yaozhao.OverDueRemote;
import com.dt76.smallloanbackenduser.utils.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
@RequestMapping("/overDue")
public class OverdueCotroller {

    @Autowired
    private OverDueRemote overDueRemote;

    @RequestMapping("/qryPageAll")
    public String qryPageAll(Model model, Integer currentPageNo,
                             @RequestParam(value = "userName",required = false)String userName,
                             @RequestParam(value = "phoneNumber",required = false)String phoneNumber,
                             @RequestParam(value = "loanId",required = false)String loanId,
                             @RequestParam(value = "ContractId",required = false)String ContractId,
                             @RequestParam(value = "riskClassification",required = false)String riskClassification){

        if (currentPageNo <= 0) {
            currentPageNo = 1;
        }
        //02.调用动态查询+分页查询接口
        String paramUserName = "";
        if(userName != null && !userName.equals("")){
            paramUserName = "%"+userName+"%";
        }
        String paramPhoneNumber = "";
        if(phoneNumber != null && !phoneNumber.equals("")){
            paramPhoneNumber = phoneNumber;
        }
        String paramloanId = "";
        if(loanId != null && !loanId.equals("")){
            paramloanId = loanId;
        }
        String paramContractId = "";
        if(ContractId != null && !ContractId.equals("")){
            paramContractId = ContractId;
        }
        String paramRiskClassification = "";
        if (riskClassification != null && !riskClassification.equals("")){
           paramRiskClassification = riskClassification;
        }
        Page page = overDueRemote.qryPageAll(currentPageNo,paramUserName,paramPhoneNumber,paramloanId,paramContractId,paramRiskClassification);
        //03.组织返回值
        model.addAttribute("qryAllPageList",page.getRows());
        model.addAttribute("page",page);
        //加入动态查询条件返回
        model.addAttribute("userName",userName);
        model.addAttribute("phoneNumber",phoneNumber);
        model.addAttribute("loanId",loanId);
        model.addAttribute("ContractId",ContractId);
        model.addAttribute("riskClassification",riskClassification);
        return "/pages/yaozhao/overDue";
        }


    @RequestMapping("/qryCollectionPageAll")
    public String qryCollectionPageAll(Model model, Integer currentPageNo,
                             @RequestParam(value = "userName",required = false)String userName,
                             @RequestParam(value = "phoneNumber",required = false)String phoneNumber,
                             @RequestParam(value = "loanId",required = false)String loanId,
                             @RequestParam(value = "CollectionType",required = false)String CollectionType){

        if (currentPageNo <= 0) {
            currentPageNo = 1;
        }
        //02.调用动态查询+分页查询接口
        String paramUserName = "";
        if(userName != null && !userName.equals("")){
            paramUserName = "%"+userName+"%";
        }
        String paramPhoneNumber = "";
        if(phoneNumber != null && !phoneNumber.equals("")){
            paramPhoneNumber = phoneNumber;
        }
        String paramloanId = "";
        if(loanId != null && !loanId.equals("")){
            paramloanId = loanId;
        }
        String paramCollectionType = "";
        if (CollectionType != null && !CollectionType.equals("")){
            paramCollectionType = CollectionType;
        }
        Page page = overDueRemote.qryCollectionPageAll(currentPageNo,paramUserName,paramPhoneNumber,paramloanId,paramCollectionType);
        //03.组织返回值
        model.addAttribute("qryAllPageList",page.getRows());
        model.addAttribute("page",page);
        //加入动态查询条件返回
        model.addAttribute("userName",userName);
        model.addAttribute("phoneNumber",phoneNumber);
        model.addAttribute("loanId",loanId);
        model.addAttribute("CollectionType",CollectionType);
        return "/pages/yaozhao/collection";
    }

    }


